package com.dingwen.treasure.task.quartz.job;

import com.dingwen.treasure.base.constant.QuartzConstant;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;

/**
 * 　AbstractJob
 * 　@author dingwen
 * 　@date 2022/5/11$
 */
@Slf4j
public abstract class AbstractJob implements Job {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) {
        addExecuteStartTime(jobExecutionContext);
        //*********************//
        log.info("定时任务：{}执行",jobExecutionContext.getJobDetail().getKey().getName());
        exactExecution();
        //*********************//
    }

    private void addExecuteStartTime(JobExecutionContext jobExecutionContext) {
        jobExecutionContext.getJobDetail()
                .getJobDataMap()
                .put(QuartzConstant.EXECUTE_START_TIME, System.currentTimeMillis());
    }


    /**
     * 精确执行
     */
    protected abstract void exactExecution();
}
